<div class="panel">
    <div class="panel_content">
        <h2>修改团队收支表</h2>
        <%= render :partial => "shared/back_link" %>
        <br/>
        <br/>
        <%= error_messages_for :tour_group %>
        <%= error_messages_for :nationality %>
        <%= error_messages_for :lodging %>
        <%= error_messages_for :guide_involved %>
        <%= error_messages_for :vehicle %>
        <%= error_messages_for :outer_expense %>
        <%= error_messages_for :shopping %>
        <% form_for(@tour_group) do |f| %>
        <table class="form">
            <tr>
                <th>
                    团号
                </th>
                <td>
                    <%= f.text_field :number, :size => 20 %>
                </td>
                <th>
                    序号
                </th>
                <td>
                    <%= f.text_field :sequence, :size => 5 %>
                </td>
                <th>
                    日期
                </th>
                <td colspan="3">
                    <%= f.calendar_date_select :during_start, :size => 10, :onchange => "during_changed();" %>至 <%= f.calendar_date_select :during_end, :size => 10, :onchange => "during_changed();" %>
                </td>
            </tr>
            <tr>
                <th>
                    国籍
                </th>
                <td>
                    <%= render :partial => "dict_edit", :locals =>{:object => Nationality, :form => f} %>
                </td>
                <th>
                    人数
                </th>
                <td>
                    <%= f.text_field :people, :style => "width: 30px; text-align: center", :title => "成人" %>
                    .[<%= f.text_field :children, :style => "width: 15px; text-align: center", :title => "儿童" %>]
                </td>
                <th>
                    客源
                </th>
                <td colspan="3">
                    <%= render :partial => "dict_edit", :locals =>{:object => Customer, :form => f} %>
                </td>
            </tr>
            <tr>
                <th>
                    行程概述
                </th>
                <td colspan="7">
                    <%= f.text_area :summary, :rows => 5, :style => "width:100%" %>
                </td>
            </tr>
            <% fields_for :lodging do |lodging| %>
            <tr>
                <th>
                    酒店
                </th>
                <td>
                    <%= render :partial => "dict_edit", :locals =>{:object => Hotel, :form => lodging} %>
                </td>
                <th>
                    房费
                </th>
                <td colspan="5">
                    <%= lodging.text_field :lodging_cost, :size => 10, :onkeyup => "calc_bj_cost()" %>
                </td>
            </tr>
            <% end %>
            <% fields_for :guide_involved do |guide_involved| %>
            <tr>
                <th>
                    导游
                </th>
                <td>
                    <%= render :partial => "dict_edit", :locals =>{:object => Guide, :form => guide_involved} %>
                </td>
                <th>
                    餐费
                </th>
                <td>
                    <%= guide_involved.text_field :food_cost, :size => 10, :onkeyup => "calc_bj_cost()" %>
                </td>
                <th>
                    门票
                </th>
                <td>
                    <%= guide_involved.text_field :attraction_ticket_cost, :size => 10, :onkeyup => "calc_bj_cost()" %>
                </td>
                <th>
                    导贴
                </th>
                <td>
                    <%= guide_involved.text_field :subsidy_for_guide, :size => 10, :onkeyup => "calc_bj_cost()" %>
                </td>
            </tr>
            <% end %>
            <tr>
                <th colspan="8" class="table_header">
                    用车
                </th>
            </tr>
            <% fields_for :vehicle do |vehicle| %>
            <tr>
                <td colspan="8" style="padding:0px;">
                    <table>
                        <tr>
                            <th>
                                司机
                            </th>
                            <td>
                                <%= render :partial => "dict_edit", :locals =>{:object => Driver, :form => vehicle} %>
                            </td>
                            <th>
                                车型
                            </th>
                            <td>
                                <%= render :partial => "dict_edit", :locals =>{:object => VehicleModel, :form => vehicle} %>
                            </td>
                            <th>
                                车费
                            </th>
                            <td>
                                <%= vehicle.text_field :travel_cost, :size => 20, :onkeyup => "calc_bj_cost()" %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                用车记录
                            </th>
                            <td colspan="5" style="background-color: #f0f0f0;">
                                <%= render :partial => "tour_groups/vehicle_rent_records_new", :locals =>{:tour_group => @tour_group} %>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <% end %>
			<tr>
				<th>北京成本</th>
				<td colspan="7">
					<%= f.text_field :bj_cost, :size => 20, :onkeyup => "calc_total_cost()" %>
				</td>
			</tr>
            <tr>
                <th colspan="8" class="table_header">
                    进店
                </th>
            </tr>
            <% fields_for :shopping do |shopping| %>
            <tr>
                <td colspan="8" style="padding:0px;">
                    <table>
                        <tr>
                            <th>
                                商店
                            </th>
                            <th>
                                购物额
                            </th>
                            <th>
                                流水
                            </th>
                            <th>
                                人头费
                            </th>
                            <th>
                                人数
                            </th>
                            <th>
                                人头费总计
                            </th>
                            <th>
                                进店小计
                            </th>
                            <th>
                                结账情况
                            </th>
                        </tr>
                        <% fields_for :shopping_record_1 do |shopping_record| %>
                        <%= render :partial => "shopping_record_new", :locals =>{:shopping_record => shopping_record, :number => 1} %>
                        <% end %>
                        <% fields_for :shopping_record_2 do |shopping_record| %>
                        <%= render :partial => "shopping_record_new", :locals =>{:shopping_record => shopping_record, :number => 2} %>
                        <% end %>
                        <% fields_for :shopping_record_3 do |shopping_record| %>
                        <%= render :partial => "shopping_record_new", :locals =>{:shopping_record => shopping_record, :number => 3} %>
                        <% end %>
                        <% fields_for :shopping_record_4 do |shopping_record| %>
                        <%= render :partial => "shopping_record_new", :locals =>{:shopping_record => shopping_record, :number => 4} %>
                        <% end %>
                        <% fields_for :shopping_record_5 do |shopping_record| %>
                        <%= render :partial => "shopping_record_new", :locals =>{:shopping_record => shopping_record, :number => 5} %>
                        <% end %>
                    </table>
                </td>
            </tr>
            <tr>
                <th>
                    导游返佣金
                </th>
                <td>
                    <%= shopping.text_field :commission_from_guide, :size => 20, :onkeyup => "calc_shopping_total_cost()" %>
                </td>
                <th>
                    返还组团社
                </th>
                <td colspan="5">
                    <%= shopping.text_field :return_to_customer, :size => 10, :onkeyup => "calc_shopping_total_cost()" %>
                </td>
            </tr>
            <% end %>
            <tr>
                <th colspan="8" class="table_header">
                    外地支出
                </th>
            </tr>
            <% fields_for :outer_expense do |outer_expense| %>
            <tr>
                <td colspan="8" style="padding:0px;">
                    <table>
                        <tr>
                            <th>
                                房费
                            </th>
                            <th>
                                地接费
                            </th>
                            <th>
                                机票
                            </th>
                            <th>
                                火车票
                            </th>
							<th>
                                船票
                            </th>
                            <th>
                                小计
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <%= outer_expense.text_field :lodging_cost, :size => 10, :onkeyup => "calc_outer_expense_total_cost()" %>
                            </td>
                            <td>
                                <%= outer_expense.text_field :acceptance_cost, :size => 10, :onkeyup => "calc_outer_expense_total_cost()" %>
                            </td>
                            <td>
                                <%= outer_expense.text_field :airticket_cost, :size => 10, :onkeyup => "calc_outer_expense_total_cost()" %>
                            </td>
                            <td>
                                <%= outer_expense.text_field :trainticket_cost, :size => 10, :onkeyup => "calc_outer_expense_total_cost()" %>
                            </td>
							<td>
                                <%= outer_expense.text_field :boatticket_cost, :size => 10, :onkeyup => "calc_outer_expense_total_cost()" %>
                            </td>
                            <td>
                                <%= outer_expense.text_field :total_cost, :size => 10, :onkeyup => "calc_total_cost()" %>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <% end %>
            <tr>
                <th>
                    收费
                </th>
                <td>
                    <%= f.text_field :revenue, :size => 20, :onkeyup => "calc_profit()" %>
                </td>
				<th>
					总成本
				</th>
				<td>
					<%= f.text_field :total_cost, :size => 20, :onkeyup => "calc_profit()" %>
				</td>
                <th>
                    负责人
                </th>
                <td colspan="3">
                    <%= render :partial => "dict_edit", :locals =>{:object => Employee, :form => f, :object_string => "owner"} %>
                </td>
            </tr>
            <tr>
                <th>
                    做团利润
                </th>
                <td>
                    <%= f.text_field :profit, :size => 10, :onkeyup => "calc_total_profit()" %>
                </td>
                <th>
                    进店利润
                </th>
                <td>
                    <% fields_for :shopping do |shopping| %>
                    <%= shopping.text_field :total_cost, :size => 10, :onkeyup => "calc_total_profit()" %>
                    <% end %>
                </td>
                <th>
                    总利润
                </th>
                <td colspan="3">
                    <%= f.text_field :total_profit, :size => 10 %>
                </td>
            </tr>
        </table>
        <br/>
        <%= f.submit "保存", :class => "submit_button" %>
        <% end %>
    </div>
</div>
<script type="text/javascript">
    _translations = {
        "OK": "确定",
        "Now": "现在",
        "Today": "今天"
    }
    
    Date.weekdays = $w("日 一 二 三 四 五 六");
    Date.months = $w("一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月");
</script>
